home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOB006.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-24  |  2KB  |  74 lines

  1. program DemoB006;
  2. {------------------------------------------------------------------------------
  3.                               DBase File Lister
  4.                                    Sample 6
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        10 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.        This program demonstrates how dBase files may be indexed using
  16.        Griffin Solutions units.
  17.  
  18.        If the DEMOB1.DBF file does not exist, the program will display a
  19.        a message that the file was not found and to run DEMOB001 to make
  20.        the file.
  21.  
  22.        The program initializes a dBase file object, opens the file, creates
  23.        an index on LASTNAME, assigns the index, , and proceeds to list
  24.        selected fields from each record in LASTNAME sequence.
  25.  
  26. -------------------------------------------------------------------------------}
  27.  
  28. uses
  29.    CRT,
  30.    DOS,
  31.    GS_Date,
  32.    GS_dBase,
  33.    GS_DBFld,
  34.    GS_FileH;
  35.  
  36. var
  37.    MyFile  : GS_dBFld_Objt;
  38.    ftest   : file;
  39. begin
  40.    ClrScr;
  41.    if not GS_FileExists(ftest, 'DEMOB1.DBF') then
  42.    begin
  43.       writeln('File DEMOB1.DBF not found.  Run DEMOB001 to create.');
  44.       halt;
  45.    end;
  46.                        {The 'Real' example starts here}
  47.  
  48.    MyFile.Init('DEMOB1');          {Initialize object using the dBase III}
  49.                                   {file DEMOB1.  DBF Extension assumed}
  50.    MyFile.Open;                   {Open the object's file}
  51.  
  52.                 {use IndexTo to create the index}
  53.                 {This is only needed the first time through}
  54.                 {It can be commented out for future runs}
  55.  
  56.    MyFile.IndexTo('DEMOB6','LASTNAME');
  57.  
  58.                 {Assign the index}
  59.  
  60.    MyFile.Index('DEMOB6');
  61.  
  62.    MyFile.GetRec(Top_Record);     {Get the first record in the file}
  63.    while not MyFile.File_EOF do   {Repeat until end-of-file}
  64.    begin
  65.       writeln(MyFile.FieldGet('LASTNAME'),' ',
  66.               MyFile.FieldGet('FIRSTNAME'),'  ',
  67.               MyFile.FieldGet('BIRTHDATE'));
  68.       MyFile.GetRec(Next_Record); {Get the next sequential record}
  69.    end;
  70.    MyFile.Close;
  71.    write('Press any Key to continue:');
  72.    repeat until KeyPressed;
  73. end.
  74.